package com.gton.person.controller;

import com.gton.person.commons.ResultAdvice;
import com.gton.person.entity.Personal;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * @program: PersonalDesign
 * @description: 测试web项目||控制页面跳转
 * @author: GuoTong
 * @create: 2020-11-11 17:04
 **/
@RestController
@Api("测试：controller")
public class TestController {

    /**
     * Description: 默认情况下@RequestBody标注的对象必须包含前台传来的所有字段。
     *
     * @author: GuoTong
     * @date: 2021-01-13 16:22:49
     * @param:
     * @return:
     */
    @RequestMapping("test/time")
    public ResultAdvice layIndex(@RequestBody Personal personal) {
        System.out.println(personal);
        return ResultAdvice.OK();
    }

    /**
     * Description:  测试Springboot的web项目构建是否完成
     *
     * @author: GuoTong
     * @date: 2021-01-13 16:21:54
     * @param:
     * @return:
     */
    @ApiOperation("测试：helloworld")
    @RequestMapping("/01")
    public String helloWorldWebProject() {
        return "Hello World Web Project";
    }

    /**
     * Description: 前往首页
     *
     * @author: GuoTong
     * @date: 2021-01-13 16:21:30
     * @param:
     * @return:
     */
    @ApiOperation("测试---首页")
    @GetMapping({"/", "/index", "index.html"})
    public ModelAndView index() {

        return new ModelAndView("index");
    }

    /**
     * Description:前往登录页面
     *
     * @author: GuoTong
     * @date: 2021-01-13 16:21:10
     * @param:
     * @return:
     */
    @ApiOperation("测试---前往登录页面")
    @RequestMapping("/toLogin")
    public ModelAndView toLogin() {
        return new ModelAndView("views/login");
    }

    /**
     * Description:前往投票活动创建页
     *
     * @author: GuoTong
     * @date: 2021-01-13 16:13:33
     * @param:
     * @return:
     */
    @ApiOperation("测试---前往创建投票页面 ")
    @RequestMapping("/level1/goToVote")
    public ModelAndView goToVote() {
        return new ModelAndView("views/Vote");
    }

    /**
     * Description: 前往活动大厅
     *
     * @author: GuoTong
     * @date: 2021-01-13 16:13:20
     * @param:
     * @return:
     */
    @ApiOperation("测试---前往活动大厅 ")
    @RequestMapping("/level1/gotoActivityHall")
    public ModelAndView gotoActivityHall() {
        //templates/views/level1/Activity_Hall.html
        return new ModelAndView("views/level1/Activity_Hall");
    }

    @ApiOperation("测试---权限1开放")
    @RequestMapping("/level1/{id}")
    public ModelAndView toLevel1(@PathVariable("id") int id) {
        System.out.println(id);
        return new ModelAndView("views/level1/" + id);

    }

    @ApiOperation("测试---权限2开放")
    @RequestMapping("/level2/{id}")
    public ModelAndView toLevel2(@PathVariable("id") int id) {
        System.out.println(id);
        return new ModelAndView("views/level2/" + id);
    }

    @ApiOperation("测试---权限3开放")
    @RequestMapping("/level3/{id}")
    public ModelAndView toLevel3(@PathVariable("id") int id) {
        System.out.println(id);
        return new ModelAndView("views/level3/" + id);
    }


}
